package com.gtgj.widget.model;

import ohos.utils.zson.ZSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class TinyTimeTable{
    private String id = "";//行程id
    private String depcityname = "";   // 出发城市名称
    private String arrcityname = "";   // 到达城市名称
    private String depname = "";   // 起飞机场名称/出发高铁站名/专车出发地/汽车出发站名
    private String arrname = "";   // 到达机场名称/到达高铁站名/专车到达地/汽车到达站名
    private String depcode = "";   // 出发机场三字码/出发高铁站三字码
    private String arrcode = "";   // 到达机场三字码/到达高铁站三字码
    private String deptime = "";   // 出发时间
    private String arrtime = "";   // 到达时间
    private String duration = ""; // 行程时长，分钟数
    private String status = "";    // 主状态描述
    private String no = "";     // 航班号/车次号
    private String departdate = "";    // 起飞日期/出发日期
    private String arrivedate = "";    //到达日期
    private String tripStatusSub;
    private String passengers = "";

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getDepartdate() {
        return departdate;
    }

    public void setDepartdate(String departdate) {
        this.departdate = departdate;
    }

    public String getArrivedate() {
        return arrivedate;
    }

    public void setArrivedate(String arrivedate) {
        this.arrivedate = arrivedate;
    }

    public String getTripStatusSub() {
        return tripStatusSub;
    }

    public void setTripStatusSub(String tripStatusSub) {
        this.tripStatusSub = tripStatusSub;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDepcityname() {
        return depcityname;
    }

    public void setDepcityname(String depcityname) {
        this.depcityname = depcityname;
    }

    public String getArrcityname() {
        return arrcityname;
    }

    public void setArrcityname(String arrcityname) {
        this.arrcityname = arrcityname;
    }

    public String getDepname() {
        return depname;
    }

    public void setDepname(String depname) {
        this.depname = depname;
    }

    public String getArrname() {
        return arrname;
    }

    public void setArrname(String arrname) {
        this.arrname = arrname;
    }

    public String getDepcode() {
        return depcode;
    }

    public void setDepcode(String depcode) {
        this.depcode = depcode;
    }

    public String getArrcode() {
        return arrcode;
    }

    public void setArrcode(String arrcode) {
        this.arrcode = arrcode;
    }

    public String getDeptime() {
        return deptime;
    }

    public void setDeptime(String deptime) {
        this.deptime = deptime;
    }

    public String getArrtime() {
        return arrtime;
    }

    public void setArrtime(String arrtime) {
        this.arrtime = arrtime;
    }

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getPassengers() {
        return passengers;
    }

    public void setPassengers(String passengers) {
        this.passengers = passengers;
    }

    public static TinyTimeTable fromJson(String json){
//        TinyTimeTable tinyTimeTable = new TinyTimeTable();
//        try {
//            JSONObject jsonObject = new JSONObject(json);
//            tinyTimeTable.setId(jsonObject.optString("id"));
//            tinyTimeTable.setTriptype(jsonObject.optString("triptype"));
//            tinyTimeTable.setUrl(jsonObject.optString("url"));
//            tinyTimeTable.setDepcityname(jsonObject.optString("depcityname"));
//            tinyTimeTable.setArrcityname(jsonObject.optString("arrcityname"));
//            tinyTimeTable.setDepname(jsonObject.optString("depname"));
//            tinyTimeTable.setArrname(jsonObject.optString("arrname"));
//            tinyTimeTable.setDepcode(jsonObject.optString("depcode"));
//            tinyTimeTable.setArrcode(jsonObject.optString("arrcode"));
//            tinyTimeTable.setDeptime(jsonObject.optString("deptime"));
//            tinyTimeTable.setArrtime(jsonObject.optString("arrtime"));
//            tinyTimeTable.setDuration(jsonObject.optString("duration"));
//            tinyTimeTable.setStatus(jsonObject.optString("status"));
//            tinyTimeTable.setNo(jsonObject.optString("no"));
//            tinyTimeTable.setDepartdate(jsonObject.optString("departdate"));
//            tinyTimeTable.setArrivedate(jsonObject.optString("arrivedate"));
//            tinyTimeTable.setTripStatusSub(jsonObject.optString("tripStatusSub"));
//            if (jsonObject.has("passengers")) {
//                tinyTimeTable.passengers = new ArrayList<>();
//                JSONArray passengers = jsonObject.getJSONArray("passengers");
//                for (int i = 0; i < passengers.length(); i++) {
//                    Passenger passenger = new Passenger();
//                    passenger.coach = ((JSONObject)passengers.get(i)).optString("coach");
//                    passenger.name = ((JSONObject)passengers.get(i)).optString("name");
//                    passenger.seatno = ((JSONObject)passengers.get(i)).optString("seatno");
//                    tinyTimeTable.passengers.add(passenger);
//                }
//            }
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//        return tinyTimeTable;
        try {
            TinyTimeTable tinyTimeTable = ZSONObject.stringToClass(json, TinyTimeTable.class);
            return tinyTimeTable;
        } catch (Exception e) {

        }
        return new TinyTimeTable();
    }

    @Override
    public String toString() {
        return "TinyTimeTable{" +
                "id='" + id + '\'' +
                ", depcityname='" + depcityname + '\'' +
                ", arrcityname='" + arrcityname + '\'' +
                ", depname='" + depname + '\'' +
                ", arrname='" + arrname + '\'' +
                ", depcode='" + depcode + '\'' +
                ", arrcode='" + arrcode + '\'' +
                ", deptime='" + deptime + '\'' +
                ", arrtime='" + arrtime + '\'' +
                ", duration='" + duration + '\'' +
                ", status='" + status + '\'' +
                ", passengers=" + passengers +
                ", no='" + no + '\'' +
                ", departdate='" + departdate + '\'' +
                ", arrivedate='" + arrivedate + '\'' +
                ", tripStatusSub='" + tripStatusSub + '\'' +
                '}';
    }
}
